<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Promise的使用</title>
</head>
<body>

<script>
    // 1,使用setTimeout
    // setTimeout(() => {
    //     console.log("Hello World");
    // }, 2000)

    // 参数 -> 函数(resolve, reject)
    new Promise((resolve, reject) => {
        setTimeout(() => {
            resolve()
            reject("error message")
        }, 2000)
    }).then(() => {
        console.log("Hello World");

        return new Promise((resolve, reject) => {
            setTimeout(() => {
                resolve()
            }, 2000)
        }).then(() => {
            console.log("Hello Vue");

            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve()
                }, 2000)
            }).then(() => {
                console.log("Hello Python");
            })
        })
    }).catch(error => {
        console.log(error);
    })

</script>

</body>
</html>